<div class="wrapper wrapper-content">
<div class="ui-popover-inner" style="min-width: auto; width: 180px;">
    <div style="margin-bottom: 6px;">添加分组</div>
     <input class="form-control" id="id" value="#(imageGroup.id??)" type="hidden">
    <div style="margin-bottom: 6px;" id="error_group_name">
        <input class="form-control" id="group_name" value="#(imageGroup.group_name??)" placeholder="不超过6个字" maxlength="6" style=" width: 166px;" type="text">
        <label class="control-label" for="group_name"></label>
    </div>
</div>
 <div class="panel-footer" align="center">
        <a href="javascript:void(0);" class="btn btn-sm btn-success js-save" style="width: 48px;">确定</a>
        <a href="javascript:void(0);" class="btn btn-default js-cancel" style="width: 48px;">取消</a>
</div>
</div>
<script type="text/javascript">
$(document).ready(function() {
	$(".js-save").click(function() {
		var hasError = false;
		var params = {}, error = {};
		var group_name = $("#group_name").val(),id=$("#id").val();
		params.id=id;
		if($.trim(group_name) =="") {error.error_group_name = "分组名不能为空"; } else {error.error_group_name=""; params.groupName = $.trim(group_name);}
		for(var key in error){
			if(error[key]!=""){
				//alert(key);
				if(!hasError) hasError = true;
				$("#"+key).addClass("has-error");
				$("#"+key).find("label").text(error[key]);
			}else{
				$("#"+key).removeClass("has-error");
				$("#"+key).find("label").empty();
			}
		}
		if(hasError){
			return false;
		}
		obz.ajaxJson(obz.ctx+"/attachment/save", params, function(json) {
	
			if(json.code!=200){
				BootstrapDialog.alert({title:'提示', message:json.msg});
			}else{
				location.href=obz.ctx+"/attachment";			
			}
	          },"json");
		if(addGroupDialog != null) addGroupDialog.close();
		
		//location.href=obz.ctx+"/attachment"
	});
	
	$(".js-cancel").click(function() {
		if(addGroupDialog != null) addGroupDialog.close();
	});
});
</script>